﻿<Window x:Class="WPF101_Windows_Dialogs.MarginsDialogBox"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="clr-namespace:WPF101_Windows_Dialogs"
    Title="Margins Dialog Box" Height="190" Width="300"
    MinHeight="190"
    MinWidth="300"
    ResizeMode="CanResizeWithGrip"
    ShowInTaskbar="False"
    WindowStartupLocation="CenterOwner" 
    FocusManager.FocusedElement="{Binding ElementName=leftMarginTextBox}" Loaded="Window_Loaded">
        <Grid Margin="0,0,0,0" Name="gridControls">
            <Grid.RowDefinitions>
                <RowDefinition Height="30" />
                <RowDefinition Height="30" />
                <RowDefinition Height="30" />
                <RowDefinition Height="30" />
                <RowDefinition Height="30" />
                </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="140" />
                <ColumnDefinition Width="140"/>
            </Grid.ColumnDefinitions>
            <TextBlock Margin="10,3,3,3" Text="Left Margin:" Name="textBlock1" VerticalAlignment="Center"/>
            <TextBlock Margin="10,3,3,3" Name="textBlock2" Text="Top Margin:" Grid.Row="1" />
            <TextBlock Margin="10,3,3,3" Name="textBlock3" Text="Right Margin:" Grid.Row="2" />
            <TextBlock Margin="10,3,3,3" Name="textBlock4" Text="Bottom Margin:" Grid.Row="3" />
        <TextBox Grid.Column="1" Margin="3,3,3,3" Name="leftMarginTextBox">
            <TextBox.Text>
                <Binding Path="Left" UpdateSourceTrigger="PropertyChanged">
                    <Binding.ValidationRules>
                        <local:MarginValidationRule MinMargin="0" MaxMargin="10" />
                    </Binding.ValidationRules>
                </Binding>
            </TextBox.Text>
        </TextBox>
            <TextBox Grid.Column="1" Grid.Row="1" Margin="3,3,3,3" Name="textBox2" />
            <TextBox Grid.Column="1" Grid.Row="2" Margin="3,3,3,3" Name="textBox3" />
            <TextBox Grid.Column="1" Grid.Row="3" Margin="3,3,3,3" Name="textBox4" />        
            <WrapPanel Grid.Column="0" Grid.ColumnSpan="2" Grid.Row="4">
                <Button Name="okButton" Click="okButton_Click" IsDefault="True" Width="50" Margin="3,3,3,3">OK</Button>
                <Button Name="cancelButton" Click="cancelButton_Click" IsCancel="True" Width="50" Margin="3,3,3,3">Cancel</Button>
             </WrapPanel>
        </Grid>
</Window>
